home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / Direct3D / DXTex / readme.txt < prev    next >
Text File  |  2001-10-10  |  9KB  |  183 lines

  1. //-------------------------------------------------------------------------
  2. //
  3. // Sample Name: DxTex
  4. //
  5. // Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
  6. //
  7. //-------------------------------------------------------------------------
  8.  
  9.  
  10. Description
  11. ===========
  12. The purpose of this tool is to allow DXSDK users to easily create texture
  13. maps that use the new DXTn compression formats.  Creating a DXTn-compressed
  14. texture is actually not that difficult to do: DirectDraw's Blt function can
  15. do the conversion for you.  Advanced developers will probably want to write
  16. their own tools that meet their specific needs.  But this tool provides useful
  17. basic functionality.
  18.  
  19.  
  20. DxTex Functionality
  21. ===================
  22. Opens BMP and DDS files (See below for a description of the DDS file format)
  23. Opens BMP files as alpha channel, either explicitly or implicitly (via 
  24. foo_a.bmp naming)
  25. Saves textures in DDS format
  26. Supports conversion to all five DXTn compression formats
  27. Supports generation of mip maps (using a box filter)
  28. Supports visualization of alpha channel as a greyscale image or via a user-
  29. selectable background color
  30. Supports easy visual comparison of image quality between formats
  31.  
  32. Note: DxTex does not currently support textures with surface formats that
  33. do not contain at least an R, G, and B texture (such as D3DFMT_G16R16 and 
  34. D3DFMT_A8), although D3DX can load and save such textures in DDS format.
  35.  
  36.  
  37. User Interface
  38. ==============
  39. DxTex uses a pretty traditional user interface.  Each texture map is a 
  40. document, and several documents can be open at a time.  The one thing that
  41. is a bit unusual about the UI is that each document can hold the texture
  42. in either one or two formats at once while the document is open in DxTex.
  43. For instance, one could import a BMP file, which would automatically create
  44. a 32-bit ARGB texture.  One could then choose to convert the texture to 
  45. DXT1 format.  The document now remembers the image in *both* formats, and
  46. the user can flip between the formats by clicking in the window or by 
  47. choosing "Original" and "New" in the View menu.  This makes it easy for
  48. the user to observe any artifacts introduced by image compression, and to
  49. try several different compression formats without progressive degradation
  50. of the image  For instance, if this technique were not used and the user
  51. converted an image from ARGB to DXT1, all but one bit of alpha would be lost.
  52. If the user then decided to convert to DXT2, there would still be only two
  53. alpha levels.  With DxTex's system, the second conversion is done from the
  54. original ARGB format, and the DXT2 image will contain all 16 levels of alpha
  55. supported by DXT2.  When the image is saved, the "original" format is 
  56. discarded, and only the "new" format is stored.
  57.  
  58. There are a few consequences of this system that one must remember:
  59. - If no format conversion has been requested since the document was opened,
  60.   the one format is the "original" format and that is the format in which
  61.   the image will be written when the document is saved.
  62. - If format conversion has been requested since the document was opened, the
  63.   converted format is the "new" format and that is the format in which the
  64.   image will be written when the document is saved.
  65. - If a second format conversion is requested, the "new" format from the first
  66.   conversion is replaced with the second format.  The "original" format will
  67.   be unchanged.
  68. - Generating of mip maps applies to both formats simultaneously.
  69. - If the original format has multiple mip maps, and conversion to a new format
  70.   is requested, the new format will automatically have multiple mip maps as 
  71.   well.
  72. It's not as complicated as it sounds: with time, this two-format system 
  73. becomes natural and efficient to use.
  74.  
  75.  
  76. DxTex Performance
  77. =================
  78. DxTex uses the Direct3D Reference Rasterizer to draw the textures, 
  79. regardless of what 3D hardware is available.  So with larger textures 
  80. (greater than 256x256), the program may be somewhat slow, depending on your 
  81. CPU speed.
  82.  
  83.  
  84. DDS File Format
  85. ===============
  86. DxTex's native file format is called "DDS" file format, because it 
  87. encapsulates the information in a DirectDrawSurface.  It has the following 
  88. format:
  89.  
  90.     DWORD dwMagic (0x20534444, or "DDS ")
  91.     DDSURFACEDESC2 ddsd (this provides information about the surface format)
  92.     BYTE bData1[] (this is the surface data for the main surface)
  93.     [BYTE bData2[]...] (surface data for attached surfaces, if any, follow)
  94.  
  95. This format is easy to read and write, and supports features such as alpha
  96. and multiple mip levels, as well as DXTn compression.  The "Compress" sample 
  97. application on the DXSDK demonstrates how to properly import a DDS file.
  98.  
  99. The user should note that it is not necessary to use the DDS format in order
  100. to use DXTn-compressed textures, or vice-versa.  But the two work well 
  101. together.
  102.  
  103.  
  104. Mip Maps
  105. ========
  106. Mip mapping is a technique that improves image quality and reduces texture
  107. memory bandwidth by providing prefiltered versions of the texture image at
  108. multiple resolutions.
  109.  
  110. To generate mip maps in DxTex, the width and height of the source image must 
  111. both be powers of 2.  Choose "Generate Mip Maps" from the Format menu.  
  112. Filtering is done via a simple box filter, i.e., the four nearest pixels are
  113. averaged to produce each destination pixel.  More sophisticated filtering can
  114. be found in other image processing programs.
  115.  
  116.  
  117. Alpha
  118. =====
  119. Many texture formats include an alpha channel, which provides opacity 
  120. information at each pixel.  DxTex fully supports alpha in textures.  When
  121. importing a BMP file, if a file exists of the same size with "_a" at the end
  122. (e.g., foo.bmp and foo_a.bmp), the second file will be loaded as an alpha
  123. channel.  The blue channel of the second BMP is stored in the alpha channel.
  124. Once a document is open, the user can explicitly load a BMP file as the alpha 
  125. channel via the "Open As Alpha Channel" command on the File menu.
  126.  
  127. To view the alpha channel directly without the RGB channels, choose "Alpha
  128. Channel Only" from the View menu.  The alpha channel will appear as a 
  129. greyscale image.  Note that if no alpha channel has been loaded, the alpha
  130. channel will be 100% everywhere and the image will appear solid white when
  131. viewing "Alpha Channel Only".  To turn off "Alpha Channel Only", just choose
  132. that menu item a second time.
  133.  
  134. In the usual view, the effect of the alpha channel is visible because the 
  135. window has a solid background color which shows through the texture where the
  136. alpha channel is less than 100%.  The user can change this background color
  137. by choosing "Change Background Color" from the View menu.  This choice does
  138. not affect the texture itself or the data that is written when the file is
  139. saved.
  140.  
  141. The DXT2 and DXT4 formats use premultiplied alpha, which means that the
  142. red, green, and blue values stored in the surface are already multiplied
  143. by the corresponding alpha value.  DirectDraw cannot blit from a surface
  144. containing premultiplied alpha to one containing non-premultiplied alpha,
  145. so some DxTex operations (Open as Alpha Channel, conversion to DXT3, and
  146. conversion to DXT5) are not possible on DXT2 and DXT4 formats.  Supporting
  147. textures using these formats is difficult on Direct3D devices which do
  148. not support DXTn textures, because DirectDraw cannot handle blitting them
  149. to a traditional ARGB surface either (unless that ARGB surface uses 
  150. premultiplied alpha as well, which is rare).  So you may find it easier to
  151. use DXT3 rather than DXT2 and DXT5 rather than DXT4 when possible.
  152.  
  153.  
  154. Command-Line Options
  155. ====================
  156. Command-line options can be used to pass input files, an output file name, and
  157. processing options to DxTex.  If an output file name is specified, the program
  158. exits automatically after writing the output file, and no user interface is 
  159. presented.
  160.  
  161. dxtex [infilename] [-a alphaname] [-m] [DXT1|DXT2|DXT3|DXT4|DXT5] [outfilename]
  162.  
  163. infilename:               The name of the file to load.  This can be a BMP or 
  164.                           DDS file.
  165.  
  166. -a alphaname:             If "-a" is specified, the next parameter is the name
  167.                           of a BMP file to load as the alpha channel.  Note:
  168.                           if no alpha filename is specified, DxTex will still
  169.                           look for a file named infilename_a.bmp and, if it 
  170.                           exists, use that as the alpha channel.
  171.  
  172. -m:                       If this option is specified, mipmaps are generated.
  173.  
  174. DXT1|DXT2|DXT3|DXT4|DXT5: Specifies compression format.  If no format is 
  175.                           specified, the image will be in ARGB-8888.
  176.  
  177. outfilename:              Specifies the name of the destination file.  If this
  178.                           is not specified, the user interface will show the 
  179.                           current file and all requested operations.  If an 
  180.                           outfilename is specified, the app will exit after 
  181.                           saving the processed file without presenting a user 
  182.                           interface.
  183.